import time
# def timer(func):
#     def wrapper(*args,**kwargs):
#         start_time = time.time()
#         print(func(*args,**kwargs))
#         end_time = time.time()
#         print("耗时{}".format(end_time-start_time))
#         return func
#     return wrapper
# @timer
# def sum(x,y):
#     return x+y



# def timer(func):
#     def wrapper():
#         start_time = time.time()
#         func()
#         end_time = time.time()
#         print("耗时{}".format(end_time-start_time))
        
#     return wrapper
 
# @timer
# def sum():
#     print("hhh")
# sum()



def func(function):
    print("---------1---------")
    def func_in():
        print("-------2-------")
        function()
    return  func_in
@func
def test():
    print("-----3------")
# test= func(test)
test()




#装饰器带参数
def func_args(*args):
    print(args)
    def func(function):
        def func_in():
            print("记录日志")
            if args[0] == "ss":
                function()
                function()
            else:
                function()
        return func_in
    return func
#先执行func_args（“ss”）函数,返回函数func的引用
#@func()
#使用func装饰器对test()函数进行装饰
@func_args("ss")
def test():
    print("test")
@func_args("hh")
def test1():
    print("test1")
test()



i = 1

def bar(i):
    j = 0
    def inner():
        i += 1
        j += 1
        return j
    return inner()

bar(i)
print(i,bar())